package linkedlist.test1290;

import listbyorder.utils.ListNode;

/**
 * @author code_yc
 * @version 1.0
 * @date 2020/7/15 12:44
 */
public class Solution1 {

    public int getDecimalValue(ListNode head) {
        if (head == null) return 0;
        int ans = 0;
        ListNode t = head;
        while (t != null) {
            ans = ans * 2 + t.val;
            t = t.next;
        }
        return ans;
    }
}
